package shared.pojo.mission

import shared.Pojo._
import shared.implicits.Implicits._
import shared.tool.DefaultPickle
import upickle.default._

/** Created by yz on 15/5/2023
 */
object StampPlot extends StampPlotT {

  def pngFileNamePrefixIn = {
    s"Stamp"
  }

  def pngFileNamePrefix(idStr: String) = {
    if (idStr.nonBlank) {
      s"${idStr}/${pngFileNamePrefixIn}"
    } else {
      s"${pngFileNamePrefixIn}"
    }
  }

  def configFileName = {
    s"${name}.json"
  }

  case class LayoutData(
    width: String = "10",
    height: String = "4"
  )

  object LayoutData {
    implicit val rw = macroRW[LayoutData]
    implicit val defaultRw = DefaultPickle.macroRW[LayoutData]
  }

  case class ColorData(
    colors: List[String] = List.empty,
    groups: List[String] = List.empty
  )

  object ColorData {
    implicit val rw = macroRW[ColorData]
    implicit val defaultRw = DefaultPickle.macroRW[ColorData]
  }

  case class FontData(
    fontFamily: String = "Times",
    barAxisFont: String = "10",
    barAxisTitleFont: String = "12",
    scatterAxisFont: String = "10",
    scatterAxisTitleFont: String = "12",
    scatterTitleFont: String = "15",
  )

  object FontData {
    implicit val rw = macroRW[FontData]
    implicit val defaultRw = DefaultPickle.macroRW[FontData]
  }

  case class Request(
    id: Int = 0,
    idStr: String = "",
    kind: String = s"${name}",
    layout: LayoutData = LayoutData(),
    color: ColorData = ColorData(),
    font: FontData = FontData()
  )

  object Request {
    implicit val rw = macroRW[Request]
    implicit val defaultRw = DefaultPickle.macroRW[Request]
  }

}
